package com.microcity.newframe.app;

import android.app.Application;
import android.content.Context;

import com.microcity.newframe.di.basecomponents.ApplicationComponent;
import com.microcity.newframe.di.basecomponents.DaggerApplicationComponent;
import com.microcity.newframe.di.basemodules.ApplicationModule;
import com.microcity.newframe.rxbus.RxBus;
import com.microcity.newframe.utils.SystemUtil;

/**
 * Created by long on 2016/8/19.
 * Application
 */

public class App extends Application {

    private static ApplicationComponent sAppComponent;
    private static Context sContext;

    // 因为下载那边需要用，这里在外面实例化在通过 ApplicationModule 设置
    private RxBus mRxBus = new RxBus();


    @Override
    public void onCreate() {
        super.onCreate();
        _initInjector();
    }


    /**
     * 初始化注射器
     */
    private void _initInjector() {
        // 这里不做注入操作，只提供一些全局单例数据
        sAppComponent = DaggerApplicationComponent.builder()
                .applicationModule(new ApplicationModule(this, mRxBus))
                .build();
    }

    public static ApplicationComponent getAppComponent() {
        return sAppComponent;
    }

    public static Context getContext() {
        return sContext;
    }

    public static String getVersionName() {
        return SystemUtil.getAppVersionName(sContext);
    }
}
